import React from "react";
import PasswordModal, { usePasswordModal } from "@/components/Modals/Password";
import { FullScreenLoader } from "@/components/Preloader";
// import Home from "./Home";  //首页引导页面
import DnDFileUploaderWrapper, {
  DnDFileUploaderProvider,
} from "@/components/WorkspaceChat/ChatContainer/DnDWrapper";

import DefaultChatContainer from "@/components/DefaultChat";
import { isMobile } from "react-device-detect";
import Sidebar, { SidebarMobileHeader } from "@/components/Sidebar";
import Navbar from "@/components/Navbar";
// import { userFromStorage } from "@/utils/request";

export default function Main() {
  const { loading, requiresAuth, mode } = usePasswordModal();

  if (loading) return <FullScreenLoader />;
  // if (requiresAuth !== false)
  //   return <>{requiresAuth !== null && <PasswordModal mode={mode} />}</>;

  // const user = userFromStorage();
  return (
    <div className="w-screen h-screen overflow-hidden bg-theme-bg-container flex">
      {!isMobile ? <Sidebar /> : <SidebarMobileHeader />}
      <div className="flex-1">
        <Navbar />
        {/* {!!user && user?.role !== "admin" ? <DefaultChatContainer /> : <Home />} */}
        <DnDFileUploaderProvider>
          <div
            style={{ height: isMobile ? "100%" : "calc(100% - 50px)" }}
            className="transition-all duration-500 relative md:mr-[16px] w-full h-full overflow-y-scroll no-scroll z-[2] chat-container-wrap"
          >
            <DnDFileUploaderWrapper>
              <DefaultChatContainer />
            </DnDFileUploaderWrapper>
          </div>
        </DnDFileUploaderProvider>
      </div>
    </div>
  );
}
